package ninder.system.control;

import ninder.system.control.UserManager.UserInfo;
import ninder.system.util.Base64Coder;
import ninder.system.util.MountIDSession;

public class VacineMeService   {

	private UserManager userControler;

	private AccessPermissionsManager accessPermissionsManager;

	private SessionsManager sessionsManager;
	
	

	public VacineMeService() {

		this.userControler = UserManager.getInstance();
		this.accessPermissionsManager = AccessPermissionsManager.getInstance();
		this.sessionsManager = SessionsManager.getInstance();
		
	}

	
	public String login(String login, String password) {

		String idType = userControler.getUserInfo(login, UserInfo.ID_TYPE);

		accessPermissionsManager.verifyPermissionToLogin(idType);

		String truePassword = userControler.getUserInfo(login,UserInfo.PASSWORD);

		String sessionID = "";

		if (password.equals(Base64Coder.decodeString(truePassword))) {

			sessionID = MountIDSession.generateIDSession();

		} else {
           
			
		}
		sessionsManager.addSession(sessionID, userControler.getUser(login));
		return sessionID;

	}

	

}
